#include <iostream>
#include <string>
#include <sstream>
#include "Product.h"

using namespace std;

Product::Product(string id, string brand, int stock, int price){
	this->id = id;
	this->brand = brand;
	this->stock = stock;
	this->price = price;
}

string Product::getID(){
	return this->id;
}

int Product::getPrice(){
	return this->price;
}

int Product::getStock(){
	return this->stock;
}

void Product::setStock(int amount){
	this->stock = amount;
}

bool Product::isLarger(int compareFactor, Product *product2){
	switch (compareFactor){
	case 0: //compare by ID
		return this->id.compare(product2->id) > 0;
	case 1: //compare by brand
		return this->brand.compare(product2->brand) > 0;
	case 2: //compare by stock
		return this->stock> product2->stock;
	case 3: //compare by price
		return this->price> product2->price;
	default: //compare by ID <- won't be called under proper communication between classes
		return this->id.compare(product2->id) > 0;
	}
}

string Product::int2str(int &i){
	string s;
	stringstream ss(s);
	ss << i; //set int into string
	return ss.str();
}